# 1merge
MERGE = task_1merge.cc
MERGE_LIB = libtask_1merge.so
# a
CJC = task_acase_jump_cbt.cc
CJC_LIB = lib_acase_jump_cbt.so

HJC = task_ahang_jump_cbt.cc
HJC_LIB = lib_ahang_jump_cbt.so
# b
COP = task_bcase_omp.cc
COP_LIB = lib_bcase_omp.so

HOP = task_bhang_omp.cc
HOP_LIB = lib_bhang_omp.so
# c
CPL = task_ccase_pool.cc
CPL_LIB = lib_ccase_pool.so

HPL = task_chang_pool.cc
HPL_LIB = lib_ahang_pool.so
#d
CLK = task_dcase_lock.cc
CLK_LIB = lib_dcase_lock.so

HLK = task_dhang_lock.cc
HLK_LIB = lib_dhang_lock.so


LOOP = 10
NUM = 32768
TOL = 1e-13
CC = gcc

# 赛方的版本
gold: libcompetition.out 
	./testApp -load ./libcompetition.out -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL) 
#1 merge 合并taskB中多个循环+临时变量
merge:$(MERGE)
	$(CC) $(MERGE) -O2 -shared -fPIC  -o $(MERGE_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
merge_run:$(MERGE_LIB)
	./testApp -load ./$(MERGE_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL) 
# case_jump_cbt
cjc:$(CJC)
	$(CC) $(CJC) -O2 -lpthread -shared -fPIC  -o $(CJC_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
cjc_run:$(CJC_LIB)
	./testApp -load ./$(CJC_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL) 
# hang_jump_cbt
hjc:$(HJC)
	$(CC) $(HJC) -O2 -lpthread -mavx -shared -fPIC  -o $(HJC_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
hjc_run:$(HJC_LIB)
	./testApp -load ./$(HJC_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

# case_omp
cop:$(COP)
	$(CC) $(COP) -O2 -fopenmp -shared -fPIC  -o $(COP_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
cop_run:$(COP_LIB)
	./testApp -load ./$(COP_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)
# hang_omp
hop:$(HOP)
	$(CC) $(HOP) -O2 -fopenmp -mavx -shared -fPIC  -o $(HOP_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
hop_run:$(HOP_LIB)
	./testApp -load ./$(HOP_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

# case_pool
cpl:$(CPL)
	$(CC) $(CPL) thpool.c -O2 -lpthread -shared -fPIC  -o $(CPL_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
cpl_run:$(CPL_LIB)
	./testApp -load ./$(CPL_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

# hang_pool
hpl:$(HPL)
	$(CC) $(HPL) thpool.c -O2 -lpthread -mavx -shared -fPIC  -o $(HPL_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
hpl_run:$(HPL_LIB)
	./testApp -load ./$(HPL_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)


# case_lock_cbt
clk:$(CLK)
	$(CC) $(CLK) -O2 -lpthread -shared -fPIC  -o $(CLK_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
clk_run:$(CLK_LIB)
	./testApp -load ./$(CLK_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)

# hang_lock_cbt
hlk:$(HLK)
	$(CC) $(HLK) -O2 -lpthread -mavx -shared -fPIC  -o $(HLK_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin
hlk_run:$(HLK_LIB)
	./testApp -load ./$(HLK_LIB) -loop $(LOOP) -matrixnum $(NUM) -seed $(SEED)  -tol $(TOL)


clean:
	rm -f *.so *.o

#allm1:$(ALLM1)
#	g++ $(ALLM1) -O2 -mavx -fopenmp -shared -fPIC  -o $(ALLM1_LIB) -ffast-math -march=native -funroll-loops -malign-double -minline-all-stringops -ftree-parallelize-loops=64 -flto -fuse-linker-plugin

#allm1_run:$(ALLM1_LIB)
#	numactl --interleave=all ./testApp -load ./$(ALLM1_LIB) -loop $(LOOP) -matrixnum $(NUM)  -seed $(SEED)  -tol $(TOL)